package com.company.gxcpc2020;

import java.util.Scanner;
import java.util.stream.IntStream;

public class GxcpcA {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt(), k = sc.nextInt(), d = sc.nextInt();
            int[] computer = new int[n];
            for (int i = 0; i < n; i++) {
                int a = sc.nextInt(), b = sc.nextInt(), c = 1;
                while (true) {
                    double v = a / (double) c + b;
                    if (v <= d) {
                        break;
                    } else {
                        c++;
                    }
                }
                computer[i] = c;
            }
            int sum = IntStream.of(computer).limit(k).reduce(Integer::sum).getAsInt();

            System.out.println(sum);
        }
    }
}
